/*
 * Copyright 2020-2030 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.gitee.minimalismstyle.fresh.common.dubbo.annotation

import org.apache.dubbo.common.constants.CommonConstants
import org.apache.dubbo.config.annotation.DubboService
import org.apache.dubbo.config.annotation.Method
import java.lang.annotation.*
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy.*
import java.lang.annotation.Target
import kotlin.reflect.KClass

/**
 *  定制的DubboService
 * @author maoxiaodong
 */
@Documented
@Retention(RUNTIME)
@Target(ElementType.TYPE)
@Inherited
@DubboService
annotation class FreshDubboService(

    /**
     * Interface class, default value is void.class
     */
    val interfaceClass: KClass<*> = Unit::class,

    /**
     * Interface class name, default value is empty string
     */
    val interfaceName: String = "",

    /**
     * Service version, default value is empty string
     */
    val version: String = "",

    /**
     * Service group, default value is empty string
     */
    val group: String = "",

    /**
     * Service path, default value is empty string
     */
    val path: String = "",

    /**
     * Whether to export service, default value is true
     */
    val export: Boolean = true,

    /**
     * Service token, default value is empty string
     */
    val token: String = "",

    /**
     * Whether the service is deprecated, default value is false
     */
    val deprecated: Boolean = false,

    /**
     * Whether the service is dynamic, default value is true
     */
    val dynamic: Boolean = true,

    /**
     * Access log for the service, default value is ""
     */
    val accesslog: String = "",

    /**
     * Maximum concurrent executes for the service, default value is 0 - no limits
     */
    val executes: Int = 0,

    /**
     * Whether to register the service to register center, default value is true
     */
    val register: Boolean = true,

    /**
     * Service weight value, default value is 0
     */
    val weight: Int = 0,

    /**
     * Service doc, default value is ""
     */
    val document: String = "",

    /**
     * Delay time for service registration, default value is 0
     */
    val delay: Int = 0,

    /**
     * @see DubboService.stub
     */
    @Deprecated("")
    val local: String = "",

    /**
     * Service stub name, use interface name + Local if not set
     */
    val stub: String = "",

    /**
     * Cluster strategy, legal values include: failover, failfast, failsafe, failback, forking
     */
    val cluster: String = "",

    /**
     * How the proxy is generated, legal values include: jdk, javassist
     */
    val proxy: String = "",

    /**
     * Maximum connections service provider can accept, default value is 0 - connection is shared
     */
    val connections: Int = 0,

    /**
     * The callback instance limit peer connection
     *
     *
     * see org.apache.dubbo.rpc.Constants#DEFAULT_CALLBACK_INSTANCES
     */
    val callbacks: Int = CommonConstants.DEFAULT_CALLBACK_INSTANCES,

    /**
     * Callback method name when connected, default value is empty string
     */
    val onconnect: String = "",

    /**
     * Callback method name when disconnected, default value is empty string
     */
    val ondisconnect: String = "",

    /**
     * Service owner, default value is empty string
     */
    val owner: String = "",

    /**
     * Service layer, default value is empty string
     */
    val layer: String = "",

    /**
     * Service invocation retry times
     *
     * @see org.apache.dubbo.common.constants.CommonConstants.DEFAULT_RETRIES
     */
    val retries: Int = CommonConstants.DEFAULT_RETRIES,

    /**
     * Load balance strategy, legal values include: random, roundrobin, leastactive
     *
     * @see org.apache.dubbo.common.constants.CommonConstants.DEFAULT_LOADBALANCE
     */
    val loadbalance: String = CommonConstants.DEFAULT_LOADBALANCE,

    /**
     * Whether to enable async invocation, default value is false
     */
    val async: Boolean = false,

    /**
     * Maximum active requests allowed, default value is 0
     */
    val actives: Int = 0,

    /**
     * Whether the async request has already been sent, the default value is false
     */
    val sent: Boolean = false,

    /**
     * Service mock name, use interface name + Mock if not set
     */
    val mock: String = "",

    /**
     * Whether to use JSR303 validation, legal values are: true, false
     */
    val validation: String = "",

    /**
     * Timeout value for service invocation, default value is 0
     */
    val timeout: Int = 0,

    /**
     * Specify cache implementation for service invocation, legal values include: lru, threadlocal, jcache
     */
    val cache: String = "",

    /**
     * Filters for service invocation
     *
     * @see Filter
     */
    val filter: Array<String> = arrayOf(),

    /**
     * Listeners for service exporting and unexporting
     *
     * @see ExporterListener
     */
    val listener: Array<String> = arrayOf(),

    /**
     * Customized parameter key-value pair, for example: {key1, value1, key2, value2}
     */
    val parameters: Array<String> = arrayOf(),

    /**
     * Application spring bean name
     */
    val application: String = "",

    /**
     * Module spring bean name
     */
    val module: String = "",

    /**
     * Provider spring bean name
     */
    val provider: String = "",

    /**
     * Protocol spring bean names
     */
    val protocol: Array<String> = arrayOf(),

    /**
     * Monitor spring bean name
     */
    val monitor: String = "",

    /**
     * Registry spring bean name
     */
    val registry: Array<String> = arrayOf(),

    /**
     * Service tag name
     */
    val tag: String = "",

    /**
     * methods support
     *
     * @return
     */
    val methods: Array<Method> = arrayOf()
)